def hano(n,x,y,z):
    """
    :param n: 有n个盘子
    :param x: from
    :param y: by
    :param z: to
    :return:
    """
    if n==1:
        print(x,"->",z)
    else:
        #将n-1个盘子从x->y
        hano(n-1,x,z,y)

        #将剩余的最后一个盘子从x->z
        print(x,"->",z)

        #将剩余的n-1个盘子从y->z
        hano(n-1,y,x,z)

if __name__ == '__main__':
    n = int(input("请输入汉诺塔的层数:"))
    hano(n,"A","B","C")